﻿
@using Lib.core;
@{
    Layout = null;
}
<script src="~/ui/ueditor/ueditor.config.js"></script>
<script src="~/ui/ueditor/ueditor.all.min.js"></script>
<script src="~/ui/ueditor/lang/zh-cn/zh-cn.js"></script>
<!--style给定宽度可以影响编辑器的最终宽度-->
<script type="text/plain" id="myEditor" style="display: block; height: 500px; width: 100%;">@Html.Raw(ViewData["edit_html"])</script>

<div id="html_hidden_area" style="display:none;"></div>

<script type="text/javascript">
    //实例化编辑器
    var editor = UE.getEditor('myEditor', {
        autoHeightEnabled: true,
        autoFloatEnabled: true
    });
    function setHeight(h) {
        editor.setHeight(h);
    }
    function setWidth(w) {
        editor.setWidth(w);
    }
    //按钮的操作
    function insertHtml(html) {
        editor.execCommand('insertHtml', html)
    }
    function isFocus() {
        return editor.isFocus();
    }
    function doBlur() {
        editor.blur()
    }
    function getAllHtml() {
        return editor.getAllHtml()
    }
    function getContent() {
        return editor.getContent();
    }
    function getPlainTxt() {
        return editor.getPlainTxt();
    }
    function setContent(html, isAppendTo) {
        editor.setContent(html, isAppendTo);
    }
    function getContentTxt() {
        return editor.getContentTxt();
    }
    function hasContent() {
        return editor.hasContents();
    }
    function setFocus() {
        editor.focus();
    }
    function deleteEditor() {
        editor.destroy();
    }
    function GetHtmlImages() {
        return $('#html_hidden_area').html(getContent()).find('img');
    }
    function GetHtmlFirstImageUrl() {
        var imgs = GetHtmlImages();
        if (imgs.length > 0) { return imgs.eq(0).attr('src'); }
        return '';
    }
</script>
